import type * as T from './type'
import http from '@/utils/http'

export type * from './type'

/**
 * 公告分页
 * @param query
 */
export function pageNotice(query: T.NoticePageQuery) {
  return http.post<PageRes<T.NoticeResp[]>>(`/system/notice/page`, query)
}

/**
 * 公告详情
 * @param id
 */
export function getNotice(id: string) {
  return http.get<T.NoticeResp>(`/system/notice/detail/${id}`)
}

/**
 * 新增公告
 * @param data
 */
export function addNotice(data: any) {
  return http.post('/system/notice/create', data)
}

/**
 * 修改公告
 * @param id
 * @param data
 */
export function updateNotice(id: string, data: any) {
  return http.put(`/system/notice/update/${id}`, data)
}

/**
 * 删除公告
 * @param id
 */
export function deleteNotice(id: string) {
  return http.del(`/system/notice/delete/${id}`)
}

/**
 * 发布公告
 * @param id
 */
export function issueNotice(id: string) {
  return http.put(`/system/notice/issue/${id}`)
}

/**
 * 撤销公告
 * @param id
 */
export function revokeNotice(id: string) {
  return http.put(`/system/notice/revoke/${id}`)
}
